﻿using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net.Http;
using Neo4jConnect.Rest.Extensions.Sample;

namespace Neo4jConnect.Rest.Extensions
{
    [Export(typeof(IExtensionManager))]
    public class ExtensionManager : IExtensionManager
    {
        //[ImportMany]
        //public Lazy<IExtensionManager, INeo4jExtensionMetadata>[] Extensions { get; set; }

        [ImportMany]
        public List<INeo4jExtension> Extensions { get; set; }

        public ExtensionManager(HttpClient client)
        {
            Extensions = new List<INeo4jExtension>();

            Extensions.Add(new GetAllExtension(client));
            Extensions.Add(new DepthTwoExtension(client));
            Extensions.Add(new ShortestPathExtension(client));
        }

        public T GetExtension<T>()
        {
            return Extensions.OfType<T>().FirstOrDefault();
        }
    }
}
